	<?php 
		$ci= &get_instance();
		$match_status_array = matchStatusDataConfig();
		$team = $this->input->get('team','');
		
		$teamArray = array();
		foreach($ci->team_entity->getArrayListOfTeam() as $item){
			$teamArray[] = '"'.$item->name.'"'; 
		}
	?>
	
<script type="text/javascript">
	var teamArray = [<?php echo implode(',',$teamArray);?>];
	
	jQuery(document).ready(function() {
		jQuery( "#team" ).autocomplete({
				 source: teamArray
			});	
	});	
</script>	

	<div class="clrboth"></div>
	
	<h3>Matches of Tournament</h3>
	
	<div class="clrboth"></div>
	<div>
		<form id="matchForm" accept-charset="utf-8" method="get" name="matchForm" action="<?php echo site_url('admin/dataman/match/show');?>" >
			Search By Team:
			<input type="text" class="no-uniform" id="team" name="team" value="<?php echo $team;?>" />	
			<input type="submit" value="Search" class="no-uniform" />	
		</form>
	</div>
	<table border="0" class="table-list">
		<thead>
			<tr>
				<th>Title</th>
				<th>Home</th>
				<th>Away</th>
				<th>Status</th>
				<th>Start time</th>
				<th>End time</th>
				<th>Status</th>
				<th>In Tournament</th>
			</tr>
		</thead>
		
		<tbody>
			<?php foreach( $items['records'] as $item ): ?>
			<?php 
				$MATCH = $ci->match_entity->init('id', $item->id);
				$HOME = clone_( $ci->team_entity->init('id',$MATCH->getHome()) );
				$AWAY = clone_($ci->team_entity->init('id',$MATCH->getAway()) );
				$TOURNAMENT = $ci->tournament_entity->init('id',$item->tournament_id);
			?>
			<?php if($TOURNAMENT AND $MATCH AND $HOME AND $AWAY): ?>
			<tr>
				<td><?php echo $MATCH->getTitle(); ?></td>
				<td><?php echo $MATCH->displayMatchInfo('home'); ?></td>
				<td><?php echo $MATCH->displayMatchInfo('away'); ?></td>
				<td><?php echo $MATCH->displayMatchInfo('closed'); ?></td>
				<td><?php echo sysDateTimeFormat($MATCH->getStartTime(),DATE_FM); ?></td>
				<td><?php echo sysDateTimeFormat($MATCH->getEndTime(),DATE_FM); ?></td>	
				<td>
					<?php echo $match_status_array[$MATCH->getStatus()];?>
				</td>
				<td>
					<a href="<?php echo site_url("admin/dataman/match/in_tournament?t_id=".$TOURNAMENT->getId());?>" ><?php echo $TOURNAMENT->getName();?></a>
				</td>
			</tr>
			<?php endif; ?>
			<?php endforeach; ?>
		</tbody>
	</table>
<div class="inner"><?php //echo $items['pagination']['links'];?></div>

